// 主界面
;define(function(require, exports, module) {
    'use strict';
    var util = require("util");
    var base = require(CONFIG.BasePath + "js/logistics/base");
    var validate = require("validate");
    var lock = false;
    var init = function(){
        alert(123);
		initEvent();
    };
	var initEvent = function(){
		$("#backBtn").on("click",function(){
            window.location.href = "../demo/demo.html";
        });
        //新建Pad
        $("#main").on("click","#submitBtn",function(){
            createDevice();
        });
    };
    //创建平板
    var createDevice =function(){
        if (lock) {return;}
        lock = true;
        var promptDialog = validate.validateInput($("#createPadContainer"));
        if (promptDialog.length != 0) {
            util.alert(promptDialog);
        } else {
            var body = base.parseForm($("#createPadContainer"));
            base.fnAjax({
                action: "createDevice.json",
                async:false,
                oData: body, //传递参数
                fnSuccess: function(data) {
                    lock = false;
                    if (data.status == 200) {
                        window.location.href = "../demo/demo.html";
                    }else{
                        base.alert(2,data.message);
                    }
                },
                error: function(jqXHR, textStatus, errorThrown){
                    lock = false;
                }
            });
        }
    };
    return {
        init:init
    };
});